/*
 * @Author: HeAo
 * @Date: 2022-09-15 10:57:16
 * @LastEditTime: 2022-09-15 16:53:35
 * @LastEditors: HeAo
 * @Description: 
 * @FilePath: \第二阶段\ES6\day03类和继承\6-类继承.js
 * 别乱动！
 */
class Animal {
  constructor(name, age, weight) {
    console.log('父类构造器');
    this.name = name
    this.age = age
    this.weight = weight
  }
  sayName() {
    console.log(this.name);
  }
  static animalAttr = '父类静态属性'
  static animalMethod(d) {
    return d instanceof Animal
  }
}

// 继承 1、extends关键字继承 显示调用super()
class Dog extends Animal {
  constructor(name, age, weight, type) {
    // 2、super类似于 Animal.call(this)  继承父的实例属性
    super(name, age, weight) // 
    console.log('子类构造器');
    this.type = type
  }
  // 6、当子类存在与父类相同时，优先执行子类
  // sayName() {
  //   console.log('子类的sayName');
  // }
}
let d1 = new Dog('可乐', 12, '10kg', '金毛')
// console.log(d1); //Dog { name: '可乐', age: 12, weight: '10kg', type: '金毛' }
// 3、继承类体方法
d1.sayName() //可乐
// 4、继承静态属性
console.log(Dog.animalAttr); //父类静态属性
// 5、继承静态方法
console.log(Dog.animalMethod(d1)); //true